﻿using B.S.Traceability.Domain;
using B.S.Traceability.Error;
using B.S.Traceability.Read.API.Application.Commends.Farm;
using B.S.Traceability.Read.API.Dto;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Traceability.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class FarmsController : ControllerBase
    {

        private readonly IMediator mediator;

        public FarmsController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 显示产品信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpGet]
        public Task<APIResult<List<ProductsShoopDtos>>> GetFarmsByBatchId([FromQuery]GetFarmsByBatchIdCommends request, CancellationToken cancellationToken)
        {
            return mediator.Send(request, cancellationToken);
        }

        /// <summary>
        /// 获取养殖场信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// 
        [HttpGet]
        public Task<APIResult<List<ProductFarmsDto>>> GetFarm([FromQuery]GetFarmsCommends request, CancellationToken cancellationToken)
        {
            return mediator.Send(request, cancellationToken);
        }
    }
}
